﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;

namespace VASMide
{
    public partial class HelpBrowser : Form
    {
        public HelpBrowser()
        {
            InitializeComponent();
        }

        private void HelpBrowser_Load(object sender, EventArgs e)
        {
            foreach (string f in Directory.GetDirectories("help"))
            {
                TreeNode tn = new TreeNode();
                tn.Text = f.Substring(f.IndexOf(@"\") + 1);
                foreach (string s in Directory.GetFiles(f))
                {
                    tn.Nodes.Add(Path.GetFileNameWithoutExtension(s));
                }
                treeView1.Nodes.Add(tn);
            }

        }

        private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
        {
            if (treeView1.SelectedNode.Parent != null)
            {
                if (File.Exists(@"help\" + treeView1.SelectedNode.Parent.Text + @"\" + treeView1.SelectedNode.Text + ".rtf"))
                {
                    richTextBox1.LoadFile(@"help\" + treeView1.SelectedNode.Parent.Text + @"\" + treeView1.SelectedNode.Text + ".rtf");
                    label1.Text = treeView1.SelectedNode.Text;
                }
            }
        }
    }
}
